package tests;

import java.io.IOException;

import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;

import net.sourceforge.jeval.EvaluationException;
import exception.ExtraCharactersException;
import exception.IllegalCharacterSequenceException;
import exception.LessCharactersExeption;
import exception.NoRuleException;
import exception.UninitializedVariableException;
import utilities.VSupervisorCreator;
import utilities.XMLWriter;
import model.ProgramGraph;
import model.TransitionSystem;
import model.UnfoldingTransitionSystem;
import model.VariableHashTable;

/** Class for supervisor creation tester for graph with variables
 * @author DarkoLaptop2
 *
 */
public class SupervisorGraphWithVariablesTester {

	public static void main(String[] args) throws EvaluationException, UninitializedVariableException, IOException, IllegalCharacterSequenceException, LessCharactersExeption, ExtraCharactersException, NoRuleException, ParserConfigurationException, TransformerException {
		ProgramGraph graph=new ProgramGraph();
		graph.addNode(0, "0");
		graph.addNode(1, "1");
		graph.addNode(2, "2");
		graph.addEdge(0, "(x<100)", "x=x+1;", "a", 1);
		graph.addEdge(1, "(x<100)", "x=x+1;", "b", 0);
		graph.addEdge(0, "(x>3)", "x=x+1;", "b", 2);
		graph.setInitialNode(0);
		VariableHashTable variablesTable=new VariableHashTable();
		variablesTable.insertVariable("x",0);
		graph.setInitialVariableValues(variablesTable);
		graph.addVariableDomain("x", 0, 5);
		graph.setRestrictionFilePath("restriction.txt");
		UnfoldingTransitionSystem supervisor=VSupervisorCreator.createSupervisor(graph);
		System.out.println(supervisor.toStringTransitionPrint());
//		XMLWriter.writeXMLDocumentForSupervisor(graph, "input.jff");
		XMLWriter.writeXMLDocumentForSupervisor(supervisor, "output.jff");
	}

}
